package com.dragon.mmochat.model.enumType;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.util.MmochatUtil;

//装备类别
//注：一旦发版,如果此enum会存到数据库，则此类型只能增加,不能减少或修改名字
public enum MmochatEquipType implements MmochatCommonObjectType {
	武器(0, MmochatConstant.BMP_LIST_武器), 头盔(1, MmochatConstant.BMP_LIST_头盔), 衣服(
			2, MmochatConstant.BMP_LIST_衣服), 鞋子(3, MmochatConstant.BMP_LIST_鞋子), 玉佩(
			4, MmochatConstant.BMP_LIST_玉佩), 挂坠(5, MmochatConstant.BMP_LIST_挂坠), 手镯(
			6, MmochatConstant.BMP_LIST_手镯), 其它(100,
			MmochatConstant.BMP_LIST_武器);

	int value;
	int bmpId;

	MmochatEquipType(int value, int bmp) {
		this.value = value;
		this.bmpId = bmp;
	}

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;
	}

	public int getBmpId() {
		return bmpId;
	}

	public void setBmpId(int bmpId) {
		this.bmpId = bmpId;
	}

	public static MmochatEquipType get(int value) {
		for (MmochatEquipType type : MmochatEquipType.values()) {
			if (type.getValue() == value) {
				return type;
			}
		}
		return null;
	}

	public static MmochatEquipType getByIndex(int index) {
		int curIndex = 0;
		for (MmochatEquipType type : MmochatEquipType.values()) {
			if (curIndex == index) {
				return type;
			}
			curIndex++;
		}
		return 武器;
	}

	public static MmochatEquipType getRandomEquipTypeWithoutJewelry() {
		int index = MmochatUtil.getRandomValue(4);
		switch (index) {
		case 0:
			return 武器;
		case 1:
			return 头盔;
		case 2:
			return 衣服;
		case 3:
		default:
			return 鞋子;
		}
	}

	public static MmochatEquipType getRandomJewelryType() {
		int index = MmochatUtil.getRandomValue(3);
		switch (index) {
		case 0:
			return 玉佩;
		case 1:
			return 手镯;
		case 2:
		default:
			return 挂坠;
		}
	}
}
